package com.yuyang.wifi.dialog;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.yuyang.wifi.R;
import com.yuyang.wifi.views.XTextView;

import java.util.Random;

import androidx.annotation.Nullable;


public class NetworkContractFailureDialog extends CommonDialog {

    private TextView tvContinueTry, tvWifiName;
    private View mIvClose;
    private Context mContext;
    private XTextView xtCurrentRate, xtNextRate;
    private String mWifiName;

    public static NetworkContractFailureDialog newInstance() {
        NetworkContractFailureDialog dialog = new NetworkContractFailureDialog();
        Bundle data = new Bundle();
        dialog.setArguments(data);
        return dialog;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public int getLayoutId() {
        return R.layout.dialog_network_contract_failure_layout;
    }

    @Override
    public void viewCreated(View view, @Nullable Bundle savedInstanceState) {
        mIvClose = (View) view.findViewById(R.id.rl_close_layout);
        xtCurrentRate = (XTextView) view.findViewById(R.id.xt_current_rate);
        xtNextRate = (XTextView) view.findViewById(R.id.xt_next_rate);
        tvWifiName = (TextView) view.findViewById(R.id.tv_wifi_name);
        tvContinueTry = (TextView) view.findViewById(R.id.tv_continue_try);

        Random random = new Random();
        int num = random.nextInt(10) + 30;
        int nums = random.nextInt(10) + 60;
        xtCurrentRate.setText("当前破解成功率sBigsBlue" + num + "%eFonteBig");
        xtNextRate.setText("下次连接成功率+sBigsYellow" + nums + "%eFonteBig");

        tvWifiName.setText(mWifiName);

        tvContinueTry.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (mDialogListener != null) {
                    mDialogListener.onConfirm();
                }
            }
        });

        mIvClose.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }

    @Override
    public boolean isCancelable() {
        return true;
    }

    public void setData(Context context, String name) {
        this.mContext = context;
        mWifiName = name;
    }

}
